package com.scu.servlet;

import com.alibaba.fastjson.JSON;
import com.scu.dao.CommentDao;
import com.scu.dao.mCommentDao;
import com.scu.entity.mComment;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

@WebServlet(name = "CommentServlet", value = "/CommentServlet")
public class CommentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        List<mComment> list = null;
        try {
            list = new mCommentDao().findSpe();
            String listStr = JSON.toJSONString(list);

            PrintWriter out = response.getWriter();
            out.print(listStr);
            out.flush();
            out.close();
            System.out.println("1");
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}